<h4>模板驱动</h4>
<form #f="ngForm" (submit)="handleSubmit(f)">
  <div ngModelGroup="baseinfo">
    <input
      #username="ngModel"
      type="text"
      ngModel
      name="username"
      required
      minlength="2"
      maxlength="10"
    />
    <div *ngIf="username.touched && username.invalid && username.errors">
      <p *ngIf="username.errors && username.errors['required']">用户名必填</p>
      <p *ngIf="username.errors['minlength']">
        长度最少{{ username.errors["minlength"].requiredLength }}个字符
      </p>
    </div>
  </div>
  <input type="text" ngModel name="hobbies" />
  <button [disabled]="f.invalid">提交</button>
</form>
